<template>
  <van-cell-group class="vw-user-info" v-if="viewLoading">
		<van-cell title="账号" :value="models.user.account" />
		<van-cell title="名称" :value="models.user.name" />
		<van-cell title="云付通" :value="models.user.cloud_account" />
		<van-cell title="推荐人账号" :value="models.p_user.account" />
		<van-cell title="推荐人名称" :value="models.p_user.name" />
  </van-cell-group>
</template>

<script>
  import { Cell, CellGroup, Field, Toast } from 'vant';
  import { mapState } from 'vuex';

  export default {
    components: {
      [Cell.name]: Cell,
      [CellGroup.name]: CellGroup,
      [Field.name]: Field
    },
    data() {
      return {
        viewLoading: false
      };
    },
    computed: mapState({
      models: state => state.user
    }),
    created() {
      this.$store.dispatch('user/findFirstByTokenIsEmpty').then((res) => {
        this.viewLoading = true;
        if(res.code != 0) {
          Toast(res.msg);
          return false;
        }
      }).catch((err) => {
        this.viewLoading = true;
      });
    }
  }
</script>

<style>
  .vw-user-info {
    padding-bottom: 64px;
  }
</style>
